<?php

namespace App\Models\Biz;

use Illuminate\Database\Eloquent\Model;
use Laracasts\Presenter\PresentableTrait;

class Order extends Model  
{
	use PresentableTrait; 

	protected $table = 'biz_orders';

	protected $presenter = 'App\Http\Presenters\Biz\OrderPresenter';

	protected $guarded = array();

	public $timestamps = false;	

	/**
	 * 订单详细条目
	 * @return [type] [description]
	 */
	public function items()
	{
		return $this->hasMany('\App\Models\Biz\Item')->with('seat');
	}


	/**
	 * 订单所属的会员
	 * @return [type] [description]
	 */
	public function member()
	{
		return $this->belongsTo('\App\Models\Mgt\Member');
	}


	/**
	 * 订单所属的业务员
	 * @return [type] [description]
	 */
	public function sales()
	{
		return $this->belongsTo('\App\Models\Mgt\Sales');
	}


	/**
	 * 订单交易员
	 * @return [type] [description]
	 */
	public function staff()
	{
		return $this->belongsTo('\App\Models\Acl\Staff');
	}


	/**
	 * 订单所属的专场演出
	 * show_id <> 0
	 * @return [type] [description]
	 */
	public function show()
	{
		return $this->belongsTo('\App\Models\Mgt\Show');
	}

	//挂账单位专用
	public function signs()
	{
		return $this->belongsTo('\App\Models\Mgt\Sales','signs_id');
	}

	//签单人专用
	public function frees()
	{
		return $this->belongsTo('\App\Models\Mgt\Sales','signs_id');
	}

	public function record()
	{
		return $this->hasOne('\App\Models\Biz\Record');
	}

	public function annual()
	{
		return $this->member->cards->where('grade_id',6)->first();
	}
	
}